# -*- coding: utf-8 -*-
'''
Created on 2013-5-30
基础物品类
@author: 不懂d叛逆
'''
def split(string):
	temp = string.split("&")
	r = {}
	for t in temp:
		if len(t) > 0:
			pos = t.find("=")
			if pos != -1:
				r[t[:pos]] = t[pos + 1:]
	return r
class ccjhObj():
	def __init__(self, data = None):
		if data:
			self.data2 = data
			self.data = split(data)
		else:
			self.data = {}
			self.data2 = ""
		return

	def get(self, key):
		if key in self.data:
			return self.data[key]
		else:
			return ""

	def setTo(self, obj):
		if isinstance(obj, ccjhObj):
			self.data.update(obj.data)
		elif isinstance(obj, str):
			self.data.update(split(obj))
		return

	def getType(self):
		return int(self.get("C"))

	def ToString(self):
		return self.data2
